<?php
// 注册页
header("content-type:text/html;charset=utf-8");
$ID = $_POST['userID'];
$pwd = $_POST['userPassword'];
$name = $_POST['userName'];
$phone = $_POST['userPhone'];
include_once("conn.php");

$select = "SELECT * FROM user_infos WHERE user_ID = '" . $ID . "'";
if ($result_select = mysqli_query($connect_DB, $select)) {
    if (mysqli_num_rows($result_select) != 0) {
        echo "<script>alert('该账号已被使用！请更换后重试！');history.go(-1);</script>";
        exit();
    } else {
        $insert = "INSERT INTO user_infos(user_ID, user_Password, user_Name, user_Phone) VALUES ('" . $ID . "', '" . $pwd . "','" . $name . "','" . $phone . "')";
        if (mysqli_query($connect_DB, $insert)) {
            echo "<script>alert('注册成功！请返回登录！');location='user_login.html';</script>";
        } else {
            echo "<script>alert('注册失败！请稍后重试！');history.go(-1);</script>";
            exit();
        }
    }
} else {
    echo "<script>alert('注册失败！请稍后重试！');history.go(-1);</script>";
    exit();
}

$connect_DB->close();

?>